import Vue from 'vue'
import Vuex from 'vuex'
//模块
import testModules from './modules/testModules/testModule'
//global
import globalState from './global/globalState'
import globalMutation from './global/globalMutation'
import globalAction from './global/globalAction'
import globalGetter from './global/globalGetter'

Vue.use(Vuex)
const isDev = process.env.NODE_ENV === 'development';
export default () => {
    const store = new Vuex.Store({
        strict:isDev,
        state: globalState,
        getters: globalGetter,
        mutations: globalMutation,
        actions: globalAction,
        modules:{
            test: testModules
        }
    });
    if(module.hot){
        module.hot.accept([
            './global/globalState',
            './global/globalMutation',
            './global/globalAction',
            './global/globalGetter',
            './modules/testModules/testModule'
        ], () => {
            const newState = require('./global/globalState').default;
            const newGetters = require('./global/globalGetter').default;
            const newMutations = require('./global/globalMutation').default;
            const newActions = require('./global/globalAction').default;
            const newMuduleTest = require('./modules/testModules/testModule').default;
            store.hotUpdate({
                state: newState,
                actions: newActions,
                getters: newGetters,
                mutations: newMutations,
                modules: {
                    test: newMuduleTest
                }
            })
        })
    }
    return store;
}